package com.lh.utils;

import com.alibaba.fastjson.JSONObject;

public class IHuangGangUtil {
//    appId： HGS_JJYXDDPT
//- 接口地址： https://gateway.ihuanggang.cn/ee6316bf-ba0b-42c1-8c6f-640db684c4bc
//AES密钥： c7bo5l4buf0ladsu
//- x-hg-api-key： 1830ee2c-3be2-4a23-b725-c16b12097203
//- jssdk地址： https://kfpt.ihuanggang.cn/jssdk/js/jssdk.js
//    | appCode | HG_HNFW_SJSBPT  |
//    | appName | i黄冈惠农服务数据上报平台  |
//    | key-1   | f3d6c710-b53d-4461-aaf1-2181fa6d567b |
//    | key-2   | b1a3ed59-fa58-451c-b214-58be9dc97604  |

    private static final String appCode = "HG_HNFW_SJSBPT";
    private static final String appName = "i黄冈惠农服务数据上报平台";
    private static final String key1 = "f3d6c710-b53d-4461-aaf1-2181fa6d567b";
    private static final String key2 = "b1a3ed59-fa58-451c-b214-58be9dc97604";



    public static String jyLogin(){
        JSONObject contentJson = new JSONObject();
        contentJson.put("appCode",appCode);
        contentJson.put("appName",appName);
        contentJson.put("type",1);
        contentJson.put("busCode","ihghnfwscan");
        contentJson.put("busName","学习教育突出问题整治工作台扫码登录");
        String content = contentJson.toJSONString();
        JSONObject paramsJson = new JSONObject();
        paramsJson.put("content",content);
        paramsJson.put("expires",180);
        String result = HuangGangPtReqUtil.httpRequestJson("https://gateway.ihuanggang.cn/464b924ca93f46f3b34b1e479dff34b3",key1,paramsJson.toJSONString());
        System.out.println(result);
        JSONObject jsonObject = JSONObject.parseObject(result);
        if (jsonObject!=null && jsonObject.getString("data")!=null){
            String data = jsonObject.getString("data");
            return data;
        }
        return result;
    }


    public static String login(){
        JSONObject contentJson = new JSONObject();
        contentJson.put("appCode",appCode);
        contentJson.put("appName",appName);
        contentJson.put("type",1);
        contentJson.put("busCode","ihghnfwscan");
        contentJson.put("busName","i黄冈惠农服务数据上报平台扫码登录");
        String content = contentJson.toJSONString();
        JSONObject paramsJson = new JSONObject();
        paramsJson.put("content",content);
        paramsJson.put("expires",180);
        String result = HuangGangPtReqUtil.httpRequestJson("https://gateway.ihuanggang.cn/464b924ca93f46f3b34b1e479dff34b3",key1,paramsJson.toJSONString());
        System.out.println(result);
        JSONObject jsonObject = JSONObject.parseObject(result);
        if (jsonObject!=null && jsonObject.getString("data")!=null){
            String data = jsonObject.getString("data");
            return data;
        }
        return result;
    }

    public static String getCodeResult(String uuid){
//        - 测试接口地址：
//        http://hgcity-dev.chutianyun.gov.cn:8016/gateway/2f8c7265c4274eca92ec1b583b34fa0d
//        - 正式接口地址： https://gateway.ihuanggang.cn/2f8c7265c4274eca92ec1b583b34fa0d
//        - x-hg-api-key： 13ded457-66f4-4f1d-abb9-df25cc936ebf
        JSONObject paramsJson = new JSONObject();
        paramsJson.put("uuid",uuid);
        String result = HuangGangPtReqUtil.httpRequestJson("https://gateway.ihuanggang.cn/e70f563986b2485fbe6cfebf06d85b44",key2,paramsJson.toJSONString());
        JSONObject jsonObject = JSONObject.parseObject(result);
        System.out.println(result);
        if (jsonObject!=null && jsonObject.getString("data")!=null){
            String data = jsonObject.getString("data");
            return data;
        }
        return null;
    }




    public static void main(String[] args) {
//        String result = login("BH9ySLFaVp9T/mqow/w+p3mTBbhY5QcrP2mC7CVB5D3ez8nJ3gkYHRYj576PWL1afVqNAxfTueWNlSVmDF/hQDUwk27+vrSfnc99OyC5B805skeApJou5HchSPYsuEN+zOS5kOY4SFsdivJSoRQgGA==");
//        System.out.println(result);
        String result = login();
        System.out.println(result);

//        HgReminderData hgReminderData = new HgReminderData();
//        hgReminderData.setReminderTitle("GDP数据上传提醒");
//        hgReminderData.setReminderContent("本月10号该上传GDP指标数据了");
//        hgReminderData.setIHgUser("1834603394435493889");
//        sendMsg(hgReminderData);

    }



}
